function [ A ] = assemblyMomentMatrix( x, xNodes, weights, poliBaseType, order )
%ASSEMBLYMOMENTMATRIX Assembles the moment matrix spational gradient
%                     for a sample point. 
%   INPUT:
%
%   x            : Sample point.
%   xNodes       : List of all domain's nodes.
%   gradWeights  : Spatial gradient of the weight function evaluated at
%                  each point.
%   poliBaseType : Type of the polinomial base of p(x).
%   order        : Order of the polinomial base of p(x).
%
%   OUTPUT:
%
%   A            : Spatial gradient of the moment matrix, a three
%                  dimensional matrix, where the last dimension states for
%                  the spatial dimension.

% p(x) = poliBase(x,k,'baseType'); % Vector p(x) - Not bases yet

nBaseElements = getPolibaseDimension (order);

A = zeros(nBaseElements, nBaseElements);

for a = 1:size(xNodes,1);
    p_xa = poliBase(xNodes(a,:), order, poliBaseType);
    if (weights(a) ~= 0)
        A = A + weights(a) * tensorProduct(p_xa, p_xa, size(p_xa,2));
    end;
        
end;

    
end



